<template>

  <data-table
    ref="pagingTable"
    :options="options"
    :list-query="listQuery"
  >
    <template #filter-content>
      <el-input v-model="listQuery.params.fileName" placeholder="搜索课件名称" style="width: 200px;" class="filter-item" />
      <el-button type="primary" icon="el-icon-download" style="float: right" size="small" class="filter-item" @click="handleExport">导出</el-button>
    </template>

    <template #data-columns>

      <el-table-column
        label="课件名称"
        prop="fileName"
      />

      <el-table-column
        label="学习人数"
        prop="learnUser"
        align="center"
      />

      <el-table-column
        label="学完人数"
        prop="finishUser"
        align="center"
      />

      <el-table-column
        label="学完比例%"
        prop="passRate"
        align="center"
      />

    </template>

  </data-table>

</template>

<script>
import DataTable from '@/components/DataTable'
import { apiExportFileStat } from '@/api/stat/course'

export default {
  name: 'FileStatPaging',
  components: { DataTable },
  props: {
    courseId: String
  },
  data() {
    return {

      listQuery: {
        current: 1,
        size: 10,
        params: {
          courseId: this.courseId,
          catId: null
        }
      },

      options: {

        // 可批量操作
        multi: false,

        // 列表请求URL
        listUrl: '/api/stat/course/file-stat-paging'
      }
    }
  },

  created() {
    this.listQuery.params.courseId = this.courseId
  },

  methods: {

    // 导出数据
    handleExport() {
      apiExportFileStat(this.listQuery.params)
    }
  }
}
</script>

